const fp = require("lodash/fp");
const _ = require("lodash");
const cars = [
    {name:"Jaguar XKR-S",horsepower:41,dollar_value:81,in_stock:true},
    {name:"Aston Martin One-77",horsepower:42,dollar_value:82,in_stock:false},
    {name:"Audi R8",horsepower:43,dollar_value:83,in_stock:true},
    {name:"Pagani Huayra",horsepower:44,dollar_value:84,in_stock:false},
]

let _underscore = fp.replace(/\W+/g, '_');

let sanitizeNames = function(cars) {
    return _.map(cars, function(car) {
        let carFn = fp.flowRight(_underscore, fp.toLower, fp.prop('name'))
        
        return _.set(car, 'name', carFn(car));
    })
};



console.log(sanitizeNames(cars));